package com.yboot.starter.tenant.core.websocket;

import com.yboot.starter.tenant.core.api.TenantIdApi;
import com.yboot.starter.tenant.core.context.TenantContextHolder;

public class TenantSaTokenChannelInterceptor
  //      extends SaTokenChannelInterceptor
{
//    private final TenantIdApi tenantIdApi;
//
//    public TenantSaTokenChannelInterceptor(PlatformSupportedUserDetailsService userDetailsService, StompPlatformSaTokenAuthenticationHandler stompPlatformSaTokenAuthenticationHandler, TenantIdApi tenantIdApi) {
//        super(userDetailsService, stompPlatformSaTokenAuthenticationHandler);
//        this.tenantIdApi = tenantIdApi;
//    }
//
//    public Message<?> preSend(Message<?> message, MessageChannel channel) {
//        Message<?> superMessage = super.preSend(message, channel);
//        StompHeaderAccessor accessor = (StompHeaderAccessor)MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
//        if (accessor != null && !StompCommand.CONNECT.equals(accessor.getCommand())) {
//            Principal user = accessor.getUser();
//            if (user instanceof SaTokenVerifyAuthenticationToken) {
//                SaTokenVerifyAuthenticationToken authenticationToken = (SaTokenVerifyAuthenticationToken)user;
//                TenantContextHolder.setTenantId(this.tenantIdApi.getTenantId(authenticationToken.getAuthenticatedUser().getPlatform(), authenticationToken.getAuthenticatedUser().getUserId()));
//            }
//        }
//
//        return superMessage;
//    }
}